const Controller = require('egg').Controller;
class BrokerController extends Controller {
	async getBroker() {
		const { ctx,app} = this
		const data = await ctx.service.broker.getBroker();
		ctx.body = {
			code: 1,
			data
		}
	}
	async delBroker() {
		const { ctx,app} = this
		const data = await ctx.service.broker.delBroker();
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '删除成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '删除失败'
			}
		}
	}
	async addBroker() {
		const { ctx,app} = this
		const data = await ctx.service.broker.addBroker();
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '添加成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '添加失败'
			}
		}
	}
	async editBroker() {
		const { ctx,app} = this
		const data = await ctx.service.broker.editBroker();
		if (data.affectedRows >= 1) {
			ctx.body = {
				code: 1,
				message: '编辑成功'
			}
		} else {
			ctx.body = {
				code: 0,
				message: '编辑失败'
			}
		}
	}
}

module.exports = BrokerController;